import React, { Component } from 'react';
import { connect } from 'react-redux'  
import { Modal, Form, Input, Radio, TreeSelect, Select } from 'antd';
const TreeNode = TreeSelect.TreeNode;
const FormItem = Form.Item;
const RadioGroup = Radio.Group;

class IpParamModal extends Component {
  constructor(props) {
    super(props);
  }

  okHandler = () => {
     const { onOk } = this.props;
     this.props.form.validateFields((err, values) => {
      if (!err) {
        onOk(values);
      }
     });
  }; 
  
  render() {

    const { children, user, dispatch, item, depts, roles, currentDept } = this.props;
    const { getFieldDecorator } = this.props.form;
    const formItemLayout = {
      labelCol: { span: 6 },
      wrapperCol: { span: 14 },
    };  

    return (
      <span>
        <Modal
                maskClosable= {this.props.maskClosable}
                confirmLoading= {this.props.confirmLoading}
                title={this.props.title}
                visible={this.props.visible}
                onOk={this.okHandler}
                onCancel={this.props.onCancel}
                key={this.props.newKey}
        >
          <Form layout='horizontal' onSubmit={this.okHandler}>
            <FormItem style={{marginBottom:'0px'}}>
              {getFieldDecorator('id',{initialValue:item.id_})(
                <Input type="hidden"/>
              )}
            </FormItem>
            <FormItem
                  {...formItemLayout}
                  label="网络名称"
                  hasFeedback
                >
                  {
                   getFieldDecorator('networkName', {
                      initialValue: item.networkName,
                      rules: [{
                        required: true, whitespace: true, message: '请输入网络名称',
                      }]
                   })(<Input placeholder="请输入网络名称"/>)
                  }
            </FormItem>
            <FormItem
                  {...formItemLayout}
                  label="ip网段"
                  hasFeedback
                >
                  {
                    getFieldDecorator('ipSegment', {
                      initialValue: item.ipSegment,
                      rules: [{
                        required: true, whitespace: true, message: '请输入ip网段',
                      }]
                    })(<Input placeholder="请输入ip网段" />)
                  }
            </FormItem>
            <FormItem
                  {...formItemLayout}
                  label="安全网关"
                  hasFeedback
                >
                  {
                    getFieldDecorator('securityDomain', {
                      initialValue: item.securityDomain,
                      rules: [{
                        required: true, whitespace: true, message: '请输入安全网关',
                      }]
                    })(<Input placeholder="请输入安全网关" />)
                  }
            </FormItem>
          </Form>
        </Modal>
      </span>
    );
  }
    
}

export default Form.create()(IpParamModal)
